{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 安装GraphViz\n",
    "\n",
    "```sh\n",
    "sudo apt-get install graphviz\n",
    "```\n",
    "\n",
    "# 获取通道构件图。 \n",
    "\n",
    ".dot图片文件可以自动生成。(.dot是一种类似于visio的图片文件，使用开源工具[GraphViz](http://www.graphviz.org/)可以打开，会显示控件之间的关联)\n",
    "\n",
    "1. g_setenv(\"GST_DEBUG_DUMP_DOT_DIR\", \"/home/test\", TRUE);切记：此函数**必须在gst_init (&argc, &argv)之前调用**。包括一些其他环境变量应该也一样需要放在init之前。\n",
    "\n",
    "2. 通过设置环境变量`GST_DEBUG_DUMP_DOT_DIR`，设置图片.dot的存储目录后，**gst-launch-1.0在每次状态变化的时候，自动创建.dot文件。**\n",
    "\n",
    "```sh\n",
    "export GST_DEBUG_DUMP_DOT_DIR=/home/gst_graphs\n",
    "```\n",
    "\n",
    "3. 通过宏`GST_DEBUG_BIN_TO_DOT_FILE()`、`GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS()`  \n",
    "实时生成.dot文件。\n",
    "\n",
    "---\n",
    "\n",
    "# dot文件转为图片\n",
    "\n",
    "```sh\n",
    "dot test.dot -Tpng -o test.png\n",
    "```\n",
    "---\n",
    "\n",
    "Here you have an example of the kind of pipelines that playbin generates. It is very complex because playbin can handle many different cases: Your manual pipelines normally do not need to be this long. If your manual pipeline is starting to get very big, consider using playbin.\n",
    "\n",
    "![pic](https://gstreamer.freedesktop.org/documentation/tutorials/basic/images/playbin.png)\n",
    "\n",
    "To download the full-size picture, use the attachments link at the top of this page (It's the paperclip icon)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 批量转换脚本\n",
    "\n",
    ">convertPNG.py\n",
    "\n",
    "```py\n",
    "#! /usr/bin/python3\n",
    "\n",
    "import os\n",
    "import subprocess\n",
    "import time\n",
    "\n",
    "for i in os.listdir('.'):\n",
    "    if 'gst-launch' in i and i.endswith('.dot'):\n",
    "        print('convert: {}'.format(i))\n",
    "        subprocess.call('dot {} -Tpng -o {}.png'.format(i, i[:-4]), shell=True)\n",
    "subprocess.Popen('rm ./*.dot', shell=True)\n",
    "```\n",
    "\n",
    "# 清空缓存图片\n",
    "\n",
    ">clear_cache.sh \n",
    "\n",
    "```sh\n",
    "#/usr/bin/bash\n",
    "rm ./*.png\n",
    "rm ./*.dot\n",
    "```"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
